{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "43c4314c-d57c-459a-89e8-177630774f90",
   "metadata": {},
   "source": [
    " # python的基本结构类型\n",
    "\n",
    "\n",
    " ## list(列表） set(集合) turple(元祖) set(集合)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "79fa7a03-d1be-432e-971f-7b8f4a4e09ab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n"
     ]
    }
   ],
   "source": [
    "a = [0,1,2,3,4,5,6,7,8,9]\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "81ee27b9-eba8-4194-b41e-d3807ad74e10",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in a:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "3ad1fa21-7ae4-4d1f-a79b-ab6e35735200",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 8, 7, 6, 5, 4.5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "for i in range(9,-1,-1):\n",
    "    b.append(i)\n",
    "b.insert(5,4.5)\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "546e257c-ff24-48ad-a4d3-0e38860cc3cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "605645e5-5ea7-42f8-b8fe-d8c1c4f013b2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "[322, 323]\n"
     ]
    }
   ],
   "source": [
    "a = list(range(1,1001))\n",
    "print(a[0])\n",
    "print(a[321:323])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efafb577-f428-4b95-ada4-26b2514dd8c4",
   "metadata": {},
   "source": [
    " ## 字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b483435d-5fe7-4b9b-a16a-a82f87b16620",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入需要翻译的单词\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词:  apple\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "翻译结果: 苹果\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词:  苹果\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "翻译结果: apple\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词:  end\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "已结束\n"
     ]
    }
   ],
   "source": [
    "dictionary = {\n",
    "    'apple': '苹果',\n",
    "    'banana': '香蕉',\n",
    "    'orange': '橙子',\n",
    "    'grape': '葡萄',\n",
    "    'strawberry': '草莓',\n",
    "    'red': '红色',\n",
    "    'blue': '蓝色',\n",
    "    'green': '绿色',\n",
    "    'yellow': '黄色',\n",
    "    'black': '黑色',\n",
    "\n",
    "    '苹果': 'apple',\n",
    "    '香蕉': 'banana',\n",
    "    '橙子': 'orange',\n",
    "    '葡萄': 'grape',\n",
    "    '草莓': 'strawberry',\n",
    "    '红色': 'red',\n",
    "    '蓝色': 'blue',\n",
    "    '绿色': 'green',\n",
    "    '黄色': 'yellow',\n",
    "    '黑色': 'black'\n",
    "}\n",
    "while True:    \n",
    "    word = input(\"请输入单词: \").strip().lower()\n",
    "    if word in dictionary:\n",
    "        translation = dictionary[word]\n",
    "        print(f\"翻译结果: {translation}\")\n",
    "    elif word == \"\":\n",
    "        print(\"请输入需要翻译的单词\")\n",
    "    elif word == \"end\":\n",
    "        print(\"已结束\")\n",
    "        break\n",
    "    else:\n",
    "        print(\"不知道！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ffd60081-b629-4365-95ea-eda2c6355206",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
